const express = require('express');
const compression = require('compression');
const http_proxy = require('http-proxy-middleware');
const port = 4003;
const app = express();
app.use(compression());

const proxy = {
  '/tarsier-dcv/': {
    target: 'http://192.168.1.190:1661'
  },
  '/base/': {
    target: 'http://localhost:8088',
    pathRewrite: {'^/base': '/debug/base'}
  }
};

for (let key in proxy) {
  app.use(key, http_proxy(proxy[key]));
}

app.get('/', (req, res) => res.send('Hello server3!'));

app.get('/abc', (req, res) => {
  return res.redirect('https://www.baidu.com');
});

app.listen(port, () => {
  console.info(`server started in http://localhost:${port}`);
});
